Skip to content


tag  jupyter  tips  ai  deep learning  beginner  regression  reinforcement learning  q learning  gym  gymnasium  ardupilot  None  ros2  dds  micro ros  xrce  sitl  plugin  gazebo  garden  SITL  debug  rangefinder  pymavlink  mavros  distance sensor  system_time  timesync  cmake  gtest  ctest  101  cpp  c++  format  fmt  multithreading  spdlog  cyclonedds  eprosima  fastdds  aptly  apt  repository  repo  local  mirror  encryption  pgp  docker  arm  container  state  networking  network  nvidia  python  app  devcontainer  gui  tutorial  volume  mount  compose  multi-stage  stage  docker compose  git  bundle  submodules  github  hooks  pre-commit  lxd  lxc  x11  profile  vscode  marpit  presentation  marp  markdown  mermaid  mkdocs  video  ffmpeg  gstreamer  cheat-sheet  sdp  v4l2loopback  gi  kml  geo  gis  spatial  gdal  ogr  raster  vector  snippets  cheat Sheet  asyncio  future  click  cli  cupy  numpy  gpu  dev container  deb  debian  package  setup  stdeb  project  hydra  yaml  configuration  matplotlib  3d  subplot  template  black  isort  templates  cookiecutter  docs  project document  docstrings  flake8  linter  git-hook  mypy  unittest  pytest  pylint  from a-z  fixture  scope  logging  pytest.ini  mock  parameterize  enum  flag  iterator  generator  yml  logging config  tuple  namedtuple  typing  annotation  generic  literal  protocol  self  typed dict  typevar  pyzmq  zmq  msgpack  slam  cartographer  action  namespace  remap  control2  ros2_control  effort  velocity  gdb  qos  plugins  msg  node  zero-copy  shm  algorithm  calibration  diff  pid  dev  colcon  colcon_cd  settings  behavior  py_trees  bt  behavior_trees  blackboard  plot  visualization  debugging  diagnostic  DiagnosticTask  diagnostics  tutorials  gst  math  apm  rat_runtime_monitor  bag  rosbag  rosbags  tools  ros  web  rosbridge  vue  binding  discovery  gazebo-classic  launch  spawn  model  cook  camera  sensors  gps  imu  ray  gazebo_ros_ray_sensor  lidar  ultrsonic  range  ultrasonic  gazebo classic  wrench  odom  gz  sdf  world  vscode tips  gazebogz-sim-joint-position-controller-system  bridge  ign  ignition  xacro  diff_drive  odometry  joint_state  argument  OpaqueFunction  DeclareLaunchArgument  LaunchConfiguration  tmux  nav  test  rclpy  goal abort  cancel goal  action client  action server  custom messages  executor  MultiThreadedExecutor  SingleThreadedExecutor  param  dynamic-reconfigure  service  client  setup.py  package.xml  parameter  parameters  custom  msgs  executers  pub  sub  rqt  rviz  rviz2  pose  marker  tf2  local_setup  rosdep  package manager  project settings  vcstool  urdf  robot_state_publisher  urdf_to_graphiz  joint  link  zenoh  tags  hands on  webinar  cross-compiler  nano  rpi  simulation  config  material  workshope  texture  joints  tmuxp  loop device  rootfs  embedded  zah  linux  rm  ubuntu  sudo  sudoers  nopasswd  visudo  udev  key  gpg  sign  commands  update-alternative  dpkg  ip  ss  netstat  snap  deploy  ssh  systemd  socat  serial  udp  tc  mtu  select  robotics  path planning  trajectory  speed  point cloud  pcl  kalman_filter  kalman  filter  control  code  extensions  remote  json  schema  yocto  poky  qemu  projects  courses to follow  matrix  graphics  rotation  2d  drone  quad  uav  design  vrx  buoyancy 

ROS2 ignition/gz bridge#

ros_ign contains packages that provide integration between ROS2 and Ignition:

  • ros_ign: Metapackage that provides all other software packages;
  • ros_ign_image: Use image_transport to transfer the image from Ignition to the one-way transmission bridge of ROS;
  • ros_ign_bridge: Two-way transmission bridge between Ignition and ROS;
  • ros_ign_gazebo: It is convenient to use the startup files and executable files of Ignition Gazebo and ROS;
  • ros_ign_gazebo_demos: Demos using ROS-Ignition integration;
  • ros_ign_point_cloud: A plug-in used to simulate publishing point clouds to ROS from Ignition Gazebo

install#

sudo apt install ros-humble-ros-gz

Demo#

Pub keypress from gazebo fortress to ROS2 using bridge - Load bridge with mapping - Open Terminal with ROS echo command - For testing open anther Terminal with ign echo command - Run gazebo with key press plugin - Press anywhere on gazebo , both subscriber window show the keypress code

run bridge
# <topic name>@<ros2 type>@<gz type>
ros2 run ros_gz_bridge parameter_bridge \
/keyboard/keypress@std_msgs/msg/Int32@ignition.msgs.Int32
ros subscriber
ros2 topic echo /keyboard/keypress
ign echo (subscriber)
ign topic -e --topic /keyboard/keypress
ign gazebo empty.sdf

using yaml config#

ign2ros_bridge.yaml
- topic_name: /keyboard/keypress
  ros_type_name: std_msgs/msg/Int32
  ign_type_name: ignition.msgs.Int32
  direction: BIDIRECTIONAL

```bash name=”Terminal1: Run bridge ros2 run ros_gz_bridge
bridge_node
–ros-args
-p config_file:=$PWD/src/gz_demos/config/ign2ros_bridge.yaml

```bash title="Terminal2 ROS echo"
ros2 topic echo /keyboard/keypress

Terminal3 ign pub
ign topic  -t /keyboard/keypress --msgtype ignition.msgs.Int32 -p "data: 102"

Demo: using ROS2 launch file#

simple_bridge.launch.py
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch_ros.actions import Node


def generate_launch_description():
    ld = LaunchDescription()

    # Bridge
    bridge = Node(
        package="ros_gz_bridge",
        executable="parameter_bridge",
        arguments=[
            "/keyboard/keypress@std_msgs/msg/Int32@ignition.msgs.Int32",
        ],
        output="screen",
    )

    ld.add_action(bridge)
    return ld

Pub from Gazebo to ROS2#

Terminal1
ros2 launch gz_demos simple_bridge.launch.py
Terminal2
ros2 topic echo /keyboard/keypress
Terminal3
ign topic  -t /keyboard/keypress --msgtype ignition.msgs.Int32 -p "data: 1021"

Pub from ROS2 to Gazebo#

Terminal2
ign topic -e --topic /keyboard/keypress
Terminal3
ros2 topic pub /keyboard/keypress std_msgs/msg/Int32 "{data: 100}"

Demo: ROS2 launch and bridge YAML config#

Example and idea from gazebosim

bridge with yaml
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import ExecuteProcess


def generate_launch_description():
    ld = LaunchDescription()

    config = os.path.join(
        get_package_share_directory('gz_demos'),
        'config',
        'ign2ros_bridge.yaml'
        )

    # Bridge
    bridge = ExecuteProcess(
        cmd=[
            'ros2 run ros_gz_bridge parameter_bridge  --ros-args -p config_file:={}'.format(config)
            ],
        output='screen',
        shell=True
    )

    ld.add_action(bridge)
    return ld

Reference#